package com.vipboot.platform.system.api.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.vipboot.framework.biz.api.auth.ApiClientService;
import com.vipboot.framework.biz.api.auth.domain.vo.ApiClientVo;
import com.vipboot.framework.core.util.MapStructUtil;
import com.vipboot.platform.system.crud.dao.SysClientDao;
import com.vipboot.platform.system.domain.entity.SysClient;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

@RequiredArgsConstructor
@Slf4j
@Service
public class ApiClientServiceImpl implements ApiClientService {

    private final SysClientDao sysClientDao;

    @Override
    public ApiClientVo getByClientId(String clientId) {
        LambdaQueryWrapper<SysClient> lqw = Wrappers.lambdaQuery();
        lqw.eq(SysClient::getClientId, clientId);
        SysClient client = sysClientDao.getOne(lqw);
        return MapStructUtil.convert(client, ApiClientVo.class);
    }
}
